#include "HelloWorldScene.h"
#include "scene_1.h"
#include "Over.h"
using namespace cocos2d;

CCScene* HelloWorld::scene()
{
	CCScene * scene = NULL;
	// 'scene' is an autorelease object
	scene = CCScene::create();
	// 'layer' is an autorelease object
	HelloWorld *layer = HelloWorld::create();
	// add layer as a child to scene
	scene->addChild(layer);

	return scene;
}


void HelloWorld::load()
{

	CCSize size = CCDirector::sharedDirector()->getWinSize();

	CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
		"data\\exit1.png",
		"data\\exit2.png",
		this,
		menu_selector(HelloWorld::menuCloseCallback));

	pCloseItem->setPosition(ccp(370, 80));


	CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
	pMenu->setPosition(CCPointZero);

	this->addChild(pMenu, 1);

	CCMenuItemImage *pCloseItem1 = CCMenuItemImage::create(
		"data\\start1.png",
		"data\\start2.png",
		this,
		menu_selector(HelloWorld::menuCloseCallback1));
	pCloseItem1->setPosition(ccp(370, 140));


	CCMenu* pMenu1 = CCMenu::create(pCloseItem1, NULL);
	pMenu1->setPosition(CCPointZero);

	this->addChild(pMenu1, 1);

	CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("data\\gamebg1.mp3", true);
	
	CCSprite* pSprite = CCSprite::create("data\\bg.png");
	pSprite->setPosition(ccp(size.width / 2, size.height / 2));
	this->addChild(pSprite, 0);

}

bool HelloWorld::init()
{
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCSprite* logo = CCSprite::create("data\\logo.png");
	logo->setPosition(ccp(size.width / 2, size.height / 2 + 100));

	this->addChild(logo, 0);

	CCJumpBy *go = CCJumpBy::create(2.0f, ccp(0, 0), 00, 2);
	logo->runAction(go);


	CCCallFunc*call = CCCallFunc::create(this, callfunc_selector(HelloWorld::load));
	CCSequence*go_2 = CCSequence::create(go, call, NULL);
	this->runAction(go_2);
	return true;
}


void HelloWorld::menuCloseCallback(CCObject* pSender)
{

	CCDirector::sharedDirector()->end();

}

void HelloWorld::menuCloseCallback1(CCObject* pSender)
{

	CCDirector::sharedDirector()->replaceScene(
		CCTransitionSlideInB::create(1.0f, scene_1::scene())
		);

}

